using System;
using FytSoa.Common.Utils;
using System.ComponentModel.DataAnnotations;
using FytSoa.Application.Hr;
using FytSoa.Application.Sys;
using FytSoa.Common.Enum;
using FytSoa.Domain.Erp;
using SqlSugar;

namespace FytSoa.Application.Erp;

/// <summary>
/// erp-产品
/// </summary>
public class ErpProductDto : AppEntity
{
    /// <summary>
    /// 产品编号
    /// </summary>
    public string Number { get; set; }

    /// <summary>
    /// 产品名称
    /// </summary>
    [Required]
    [StringLength(100)]
    public string Name { get; set; }
    
    /// <summary>
    /// 供应商编号
    /// </summary>
    public long SupplierId { get; set; } = 0;

    /// <summary>
    /// 供应商
    /// </summary>
    public ErpSupplierSimpleDto Supplier { get; set; } = new();

    /// <summary>
    /// 产品类别编号
    /// </summary>
    [Required]
    public long TypeId { get; set; }

    /// <summary>
    /// 产品类别
    /// </summary>
    public SysCodeSimpleDto Type { get; set; } = new();

    /// <summary>
    /// 单位编号
    /// </summary>
    [Required]
    public long UnitId { get; set; }
    
    /// <summary>
    /// 产品单位
    /// </summary>
    public SysCodeSimpleDto Unit { get; set; } = new();

    /// <summary>
    /// 市场价
    /// </summary>
    [Required]
    public decimal MarketPrice { get; set; }

    /// <summary>
    /// 成交价
    /// </summary>
    [Required]
    public decimal Price { get; set; }

    /// <summary>
    /// 产品图片
    /// </summary>
    public List<ErpProduct.Image> Images { get; set; } = new();

    /// <summary>
    /// 负责人
    /// </summary>
    [Required]
    public long ChargePeopleId { get; set; }

    /// <summary>
    /// 负责人
    /// </summary>
    public HrEmployeeSimpleDto Employee { get; set; } = new();

    /// <summary>
    /// 状态
    /// </summary>
    [Required]
    public bool Status { get; set; } = true;
    
    /// <summary>
    /// 预警值0为不限制
    /// </summary>
    [Required]
    public int MinCount { get; set; } = 0;
    
    /// <summary>
    /// 是否产品
    /// </summary>
    public ErpProductTagEnum ProductTag { get; set; } = ErpProductTagEnum.Materiel;

    /// <summary>
    /// 规格
    /// </summary>
    public List<ErpProduct.Specs> Specifi { get; set; } = new();

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }


}

/// <summary>
/// erp-产品
/// </summary>
public class ErpProductSimpleDto : AppEntity
{
    public string Name { get; set; }
    
    public string Number { get; set; }
    
    /// <summary>
    /// 成交价
    /// </summary>
    public decimal Price { get; set; }
    
    /// <summary>
    /// 产品单位
    /// </summary>
    public SysCodeSimpleDto Unit { get; set; } = new();
}